<?php
//TODO: set $mydir variable!
require_once(dirname(__FILE__) . '/conf/config.php');
function __autoload($class_name) {
  if (function_exists('gen_autoload') AND gen_autoload($class_name) !== false) {
  	return;
  }
  elseif (function_exists('user_autoload') AND user_autoload($class_name) !== false) {
  	return;
  }
  
  static $mydir;
  if (is_null($mydir)) $mydir = dirname(__FILE__)."/";
  
  switch ($class_name) {
    case 'DBAdapter' : require_once $mydir . 'db/DBAdapter.php'; DBAdapter::init(); break;
    case 'ActiveRecord' :  require_once $mydir . 'db/ActiveRecord.php';  break;
    case 'OnFly' :  require_once $mydir . 'db/OnFly.php';  break;
    case 'QueryWrapper' :  require_once $mydir . 'db/QueryWrapper.php'; break;
    case 'QueryWrapperException': require_once $mydir . 'db/QueryWrapper.php'; break;
    case 'Conf' : require_once $mydir . 'conf/Conf.php';  break;
    case 'Scaffoldable' : require_once($mydir. 'scaffold/Scaffoldable.php'); break;
    case 'ScaffoldNode' : require_once($mydir.'scaffold/ScaffoldNode.php'); ScaffoldNode::$mTplEngineObj = new SmartyLocal(); break;
    case 'ScaffoldableParent' : require_once($mydir.'scaffold/ScaffoldableParent.php'); break;
    case 'SimpleTableScaffolder' : require_once($mydir.'scaffold/generic/SimpleTableScaffolder.php'); break;
    case 'Scaffolder' : require_once($mydir.'scaffold/Scaffolder.php'); break;
    case 'Exposable' : require_once($mydir.'scaffold/Exposable.php'); break;
    case 'Smarty': require_once(Conf::get('SMARTY_DIR') . 'Smarty.class.php');  break;
    case 'SmartyExt': require_once($mydir . '/smarty_ext/SmartyExt.php');  break;    
    case 'ScaffolderGenerator': require_once($mydir . 'scaffold/scaffold_gen/ScaffolderGenerator.php');  break;   
    case 'WebUtils' : require_once($mydir . 'console/WebUtils.php'); break;
    case 'Aggregatable':  require_once($mydir . 'data_aggregators/Aggregatable.php'); break;
    case 'DBDataAggregator':  require_once($mydir . 'data_aggregators/DBDataAggregator.php'); break;
    case 'AbstractController' : require_once($mydir . 'web/AbstractController.php'); break;
    case 'ParamsParser' : require_once($mydir . 'web/ParamsParser.php'); break;
    case 'ExposableArray': require_once($mydir. 'scaffold/ExposableArray.php');break;
    case 'SetGetAble' : require_once($mydir . 'db/SetGetAble.php'); break;
    case 'ARDataAggregator': require_once($mydir. 'data_aggregators/ARDataAggregator.php'); break;
    case 'CommonScaffolder': require_once($mydir. 'scaffold/CommonScaffolder.php');break;
    case 'SessionHandler': require_once($mydir. 'sessions/SessionHandler.php');break;
    case 'DBSessionLogger': require_once($mydir. 'sessions/db/DBSessionLogger.php');break;
    case 'DBSessionHandler': require_once($mydir. 'sessions/db/DBSessionHandler.php');break;
    case 'DryAbstractLogger': require_once($mydir. 'log/DryAbstractLogger.php');break;
    case 'CronController': require_once($mydir. 'cron/CronController.php');break;
  }
}
